<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./../../Template/generalTemplate.xhtml">


            <ui:define name="content">
                <h:form id="form">
                    <p:panel id="salesQuotationList" header="Credit Account List" style="height:495px;">

                        <div style="margin-top:20px;margin-left:50px;margin-right:50px;margin-bottom:20px;"> 
                            <p:dataTable id="quotation" dynamic="true" emptyMessage="No Credit Account Exists" value="#{viewCreditAccountManagedBean.getCreditAccounts()}" var ="o" paginator="true" rows="6">

                                <p:column filterBy="#{o.company.id}" filterMatchMode="contains" headerText="Client ID"
                                          style="width:200px;">
                                    #{o.company.id}
                                </p:column>

                                <p:column filterBy="#{o.company.name}" filterMatchMode="contains" headerText="Client">
                                    #{o.company.name}
                                </p:column> 

                                <p:column headerText="Current Balance">
                                    #{o.currentBalance}
                                </p:column>

                                <p:column headerText="Credit Limit">
                                    #{o.creditLimit}
                                </p:column> 

                                <p:column headerText="Action" style="text-align: center;">                                          
                                    <p:commandButton update="form:outputPanelMain" oncomplete="carDialog.show()" image="ui-icon ui-icon-pencil" title="Edit" style="margin-right: 10px;" >
                                        <f:setPropertyActionListener value="#{o}" target="#{viewCreditAccountManagedBean.selectedCreditAccount}" />  
                                    </p:commandButton>

                                </p:column>  

                            </p:dataTable>

                            <p:dialog header="Edit Credit Account" widgetVar="carDialog" resizable="false" id="carDlg"  
                                      showEffect="fade" hideEffect="explode" modal="true" width="500">  

                                <p:outputPanel id="outputPanelMain">

                                    <h:panelGrid id="display"  columns="2" cellpadding="4">  
                                        <h:outputText value="Company Id:" style="font-weight:bold"/>  
                                        <h:outputText value="#{viewCreditAccountManagedBean.selectedCreditAccount.company.id}" />
           
                                        <h:outputText value="Company Name:" style="font-weight:bold"/> 
                                        <h:outputText value="#{viewCreditAccountManagedBean.selectedCreditAccount.company.name}" />

                                        <h:outputText value="Freeze Account:" style="font-weight:bold"/> 
                                        <h:outputText value="#{viewCreditAccountManagedBean.selectedCreditAccount.frozen}" />

                                        <h:outputText value="Current Balance:" style="font-weight:bold"/> 
                                        <h:outputText value="#{viewCreditAccountManagedBean.selectedCreditAccount.currentBalance}" />

                                        <h:outputText value="Credit Limit:" style="font-weight:bold"/> 
                                        <h:inputText value="#{viewCreditAccountManagedBean.selectedCreditAccount.creditLimit}" />
                                    </h:panelGrid>



                                </p:outputPanel>

                            </p:dialog>
                        </div>




                    </p:panel>
                </h:form>
            </ui:define>



        </ui:composition>

    </body>
</html>
